/*=========================================================================
Elite College as Engines of Upward Mobility: Evidence from Colombia's Ser Pilo Paga
Authors: Juliana Londoño-Vélez, Catherine Rodriguez, Fabio Sánchez
and Luis Esteban Álvarez-Arango

Creation date: June 6th, 2025
--------------------------------------------------------------------------
Figures A8b and A9b
=========================================================================*/    

use 	"${Intermediate}/Resultados_years_pila.dta", clear

* 		Plotting conventional RD coefficient and conventional confidence intervals
drop 	cs_* ci_*
foreach r in 11 si{
	gen 	cs_`r' = cc_`r'+(1.96*sec_`r')
	gen 	ci_`r' = cc_`r'-(1.96*sec_`r')
} 
	
gen 	p=.
replace p=1 if regexm(nombre,"201304") 
replace p=2 if regexm(nombre,"201308") 
replace p=3 if regexm(nombre,"201312") 
replace p=4 if regexm(nombre,"201404") 
replace p=5 if regexm(nombre,"201408") 
replace p=6 if regexm(nombre,"201412") 
replace p=7 if regexm(nombre,"201504") 
replace p=8 if regexm(nombre,"201508") 
replace p=9 if regexm(nombre,"201512") 
replace p=10 if regexm(nombre,"201604") 
replace p=11 if regexm(nombre,"201608") 
replace p=12 if regexm(nombre,"201612")
replace p=13 if regexm(nombre,"201704") 
replace p=14 if regexm(nombre,"201708") 
replace p=15 if regexm(nombre,"201712")
replace p=16 if regexm(nombre,"201804") 
replace p=17 if regexm(nombre,"201808") 
replace p=18 if regexm(nombre,"201812")
replace p=19 if regexm(nombre,"201904") 
replace p=20 if regexm(nombre,"201908") 
replace p=21 if regexm(nombre,"201912")
replace p=22 if regexm(nombre,"202004") 
replace p=23 if regexm(nombre,"202008") 
replace p=24 if regexm(nombre,"202012")
replace p=25 if regexm(nombre,"202104") 
replace p=26 if regexm(nombre,"202108") 
replace p=27 if regexm(nombre,"202112")
replace p=28 if regexm(nombre,"202204") 
replace p=29 if regexm(nombre,"202208") 
replace p=30 if regexm(nombre,"202212")
replace p=31 if regexm(nombre,"202304") 
replace p=32 if regexm(nombre,"202308") 
replace p=33 if regexm(nombre,"202312")

twoway 	(rcap cs_11 ci_11 p if regexm(nombre,"work"), lcolor(black)) ///
		(scatter cc_11 p if regexm(nombre,"work"), ysc(r(0)) mcolor(black) msymbol(O)) ///
		,ytitle(RD Coefficient and 95% CI) ysc(r(-.1 .075)) ylabel(-0.1(.02)0.08) yline(0) ///
		xtitle("Years after high school completion") ///
		 xlabel( 2 "-1" 5 "0" 8 "1" 11 "2" 14 "3" 17 "4" 20 "5" 23 "6" 26 "7" 29 "8" 32 "9",labsize(medium)) ///
		legend(off) xsize(8) ///
		caption(Sample restricted to low-SES individuals, size(small)) graphregion(color(white)) 
graph export "${outcomes}/FigA8b.pdf", replace width(20)
			

twoway 	(rcap cs_si ci_si p if regexm(nombre,"mw"), lcolor(black)) ///
		(scatter cc_si p if regexm(nombre,"mw"), ysc(r(0)) mcolor(black) msymbol(O)) ///
		,ytitle(RD Coefficient and 95% CI) yline(0)  ylab(-.1(.05).45)  ///
		xtitle("Years after high school completion") ///
		xlabel( 2 "-1" 5 "0" 8 "1" 11 "2" 14 "3" 17 "4" 20 "5" 23 "6" 26 "7" 29 "8" 32 "9",labsize(medium)) ///
		legend(off) xsize(8) ///
		caption(Sample restricted to SABER 11-eligible individuals, size(small)) graphregion(color(white)) 
graph export "${outcomes}/FigA9b.pdf", replace width(20)
		

